// pages/workService/selectadaddress/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    addressList: [
    ],
    showModal: false,
    orderid: "",
    confirmdel: "删除确认",
    contenttitle: '你确定要删除吗,删除后不可恢复',
    selectadaddress: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.selectadaddress) {

      this.setData({
        selectadaddress: options.selectadaddress
      })


    }

    this.getSelectList();
  },

  selectaddresslist (item) {
    console.log(item)
    var province = item.currentTarget.dataset.item.province;
    var city = item.currentTarget.dataset.item.city;
    var county = item.currentTarget.dataset.item.county;
    var userName = item.currentTarget.dataset.item.userName;
    var mobile = item.currentTarget.dataset.item.mobile;
    var detil = item.currentTarget.dataset.item.detil;
    wx.redirectTo({
      url: '../../workService/documentagent/index?province=' + province + "&city=" + city + "&county=" + county + "&userName=" + userName + "&mobile=" + mobile + "&detil=" + detil,
    })




    // wx.redirectTo({
    //   url: '/pages/index/index',
    // });
  },

  getSelectList () {
    const request = {

    }
    console.log(request);
    wx.$API['workService/addressList'](request).then((response) => {
      console.log(response.data, 8989898989)

      this.setData({
        addressList: response.data
      })


    }).catch((error) => {


    })
  },

  modalCancel () {
    this.setData({
      showModal: false,
    })
  },

  modalConfirm () {
    const request = {
      id: this.data.orderid
    }
    console.log(request);
    wx.$API['workService/addressremove'](request).then((response) => {
      this.getSelectList();
      // this.onLoad();
    }).catch((error) => {


    })
  },
  removeaddress (event) {    //删除地址
    console.log(event.target.dataset.item);
    this.setData({
      showModal: true,
      orderid: event.target.dataset.item.id
    })
    this.getRemoveList();
  },
  getRemoveList () {


  },

  addaddress () {    //添加地址
    var ids = 0;   //添加id就等于1
    wx.navigateTo({
      url: '../../workService/adaddress/index?ids=' + ids
    })
  },

  Editaddress (event) {   //编辑地址
    var ids = 0;
    const request = {
      id: event.target.dataset.item.id
    }
    wx.navigateTo({
      url: '../../workService/adaddress/index?id=' + request.id + '&&ids=' + ids
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})